﻿Imports MySql.Data.MySqlClient

Public Class checkInForm


    Private Sub checkInForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        logoPic.Location = New System.Drawing.Point(((checkInPanel.Width / 2) - (logoPic.Width / 2)), 3)
        checkInPanel.Location = New System.Drawing.Point(((Me.Width / 2) - (checkInPanel.Width / 2)), ((Me.Height / 2) - (checkInPanel.Height / 2)))
    End Sub

    Private Sub checkInDatePicker_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles checkInDatePicker.ValueChanged
        If (checkInDatePicker.Value < Today) Then
            MsgBox("Start date cannot occurs before today", vbInformation)
            checkInDatePicker.Value = Today
        ElseIf (checkInDatePicker.Value > checkOutDatePicker.Value) Then
            checkOutDatePicker.Value = checkInDatePicker.Value
        End If
    End Sub



    Private Sub checkOutDatePicker_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles checkOutDatePicker.ValueChanged
        If (checkOutDatePicker.Value.Month > checkInDatePicker.Value.Month) Then
            If (checkOutDatePicker.Value < checkInDatePicker.Value) Then
                MsgBox("End date cannot occurs before start date. Please re-choose end date", vbInformation)
                checkOutDatePicker.Value = checkInDatePicker.Value
            End If
        ElseIf (checkOutDatePicker.Value.Month < checkInDatePicker.Value.Month) Then
            MsgBox("Month has past", vbInformation)
            checkOutDatePicker.Value = checkInDatePicker.Value
        ElseIf (checkOutDatePicker.Value.Month.Equals(checkInDatePicker.Value.Month And checkOutDatePicker.Value < checkInDatePicker.Value)) Then
            MsgBox("End date cannot occurs before start date. Please re-choose end date")
            checkOutDatePicker.Value = checkInDatePicker.Value
        End If
    End Sub


    Private Sub resetBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles resetBtn.Click
        adultsComboBox.SelectedIndex = 0
        childrenComboBox.SelectedIndex = 0
        checkInDatePicker.Value = Today
        checkOutDatePicker.Value = checkInDatePicker.Value
    End Sub

    Private Sub proceedBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles proceedBtn.Click
        roomForm.setCond("checkin")
        roomForm.Show()
    End Sub

    Private Sub backBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles backBtn.Click
        Me.Hide()
    End Sub
End Class